<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    request.setAttribute("basePath", request.getContextPath());
%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="${basePath}/resources/jquery/jquery-1.6.4.min.js"></script>
    <script type="text/javascript" src="${basePath}/resources/js/common/json2.js"></script>
    <link rel="stylesheet" href="${basePath}/component/JQueryzTreev3.5.14/css/zTreeStyle/zTreeStyle.css"
          type="text/css">
    <script type="text/javascript" src="${basePath}/component/JQueryzTreev3.5.14/js/jquery.ztree.core-3.5.js"></script>
    <script type="text/javascript"
            src="${basePath}/component/JQueryzTreev3.5.14/js/jquery.ztree.excheck-3.5.min.js"></script>
    <script type="text/javascript"
            src="${basePath}/component/JQueryzTreev3.5.14/js/jquery.ztree.exhide-3.5.min.js"></script>

    <script>
        $(function () {
            $.get('${basePath}/s/uc/lk/l', function (data) {
                var zNodes = new Array();
                $.each($.parseJSON(data), function (i, item) {
                    var obj = new Object();
                    obj.id = item.wid;
                    obj.pId = item.superid == null ? "" : item.superid + "";
                    obj.name = item.name;
                    if(item.lev == 0 || item.lev == -1){
                        obj.open = true;
                    }
                    zNodes.push(obj);
                });
                var setting = {
                    data: {
                        simpleData: {
                            enable: true
                        }
                    },
                    callback: {
                        onClick: doClickTreeNode
                    }
                };
                $.fn.zTree.init($("#tree"), setting, zNodes);
            });
        });
        /**
         * 树结构点击事件
         */
        function doClickTreeNode(event, treeId, treeNode) {
            $("#menuContentFrame", parent.document).attr("src", "${basePath}/s/uc/lk/e?wid=" + treeNode.id);
        }
    </script>
</head>
<body style="background-color: #eeeee2;">
<div class="treeDiv">
    <ul id="tree" class="ztree"></ul>
</div>
</body>
</html>
